var form = document.querySelector('form')
var nameInput = document.querySelector('#name')
var pwdInput = document.querySelector('#pwd')
form.onsubmit = function () {
    const name = nameInput.value
    const pwd = pwdInput.value
    // 带上用户名和密码向后端发送请求
    // { name: name, pwd: pwd } 在ES6里可以简写为{ name, pwd }
    utils.post('http://localhost/day25/el.shop/api/user/register.php', { name, pwd }, resp => {
      if (resp.code === 200) {
        alert(resp.body.msg + '，即将跳转登录页')
        location.href = '/html/login1.html'
      } else {
        // 注册失败
        alert(resp.body.msg)
      }
    })
    return false
  }